import { PageConfig } from 'next';
import anylogger from 'anylogger';
import '@mmstudio/an000042';
import an48 from '@mmstudio/an000048';
import queryallcurriculums from '../../queryallcurriculums';

const logger = anylogger('pages/api/teachgl/pk/content/query.api');

export type IData = {
	section: number;
	mon: ITbcurriculums;
	tue: ITbcurriculums;
	wen: ITbcurriculums;
	thu: ITbcurriculums;
	fri: ITbcurriculums;
	sat: ITbcurriculums;
	sun: ITbcurriculums;
}

export type Result = IData[];

export type Message = {
	class_id: string;
}

/**
 * 查询课程表
 */
const handler = an48<Result>();

handler.get(async (req, res) => {
	try {
		logger.debug('msg body:', req.body);
		const { class_id } = req.query as Message;
		const data = await queryallcurriculums(class_id);
		res.status(200).json(data);
	} catch (error) {
		logger.trace(error);
		res.status(200).json([]);
	}
});

export const config = {} as PageConfig;

export default handler;
